<?php
namespace Home\Controller;
use Think\Controller;
class CommentsController extends BaseController{
  public function addcomment(){
    $id=$_GET['id'];
        $phoneModel=M('phone');//表明,conf中定义前缀
        $phones = $phoneModel->where("id=$id")->select();

        //dump($lost);
        $this->phones=$phones;//name属性对应的值 $this->对应值=$find;
        $this->display();
       //  $id=$_GET['id'];
       // $commentModel=M('comments');//表明,conf中定义前缀
       //  $comments = $commentModel->where("id=$id")->select();

       //  // //dump($lost);
       //  $this->phones=$phones;//name属性对应的值 $this->对应值=$find;
       //  $this->display();
   
      }
      
    public function doaddcomment(){
         $data=$_POST;

         $phoneModel=M('phone');//表明,conf中定义前缀
//  $phones = $phoneModel=M('phone')->save($data);

         $commentModel=M('comments');
         $commentModel->create();
          $commentModel->createtime =  date("Y-m-d H:i:s");
         $result=$commentModel->add();
       
         if ($phoneModel->create()) {
       
  $addresult=$phoneModel->add(); 
//写入用户数据到数据库
                     if (false !== $addresult)
                             {
                            $this->success('留言成功！', '../Phones/phonelist');
                             }else{ 
                                     $this->error('数据错误'); 
                                    }


 }
}
}
